package richbar.com.richbar.activity.order;

import android.app.Activity;
import android.content.Intent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.common.base.BaseActivity;
import com.common.util.LogUtil;

import richbar.com.richbar.R;
import richbar.com.richbar.base.S;
import richbar.com.richbar.help.TitleHelp;
import richbar.com.richbar.util.NetWorkUtil;

/**
 * Created by QiYang on 2019/4/28.
 */

public class LookLogisticsAc extends BaseActivity {
    public WebView webView;
    private WebSettings webSettings;
    public static void start(Activity activity,String no) {
        Intent intent = new Intent(activity,LookLogisticsAc.class);
        intent.putExtra("no",no);
        activity.startActivity(intent);
    }
    @Override
    public int initLayout() {
        return R.layout.ac_look_logistics;
    }

    @Override
    public void initTitle() {
        new TitleHelp(this).setTitle("跟踪物流");
    }

    @Override
    public void initView() {
        webView = findViewById(R.id.webView);

    }

    @Override
    public void initData() {
        String no = getIntent().getStringExtra("no");
        String url = NetWorkUtil.URL + "/home/track/index?no=" + no;
        LogUtil.e("ADAWDAWDWADAW",url);
        webView.setFocusable(false);
        webView.loadUrl(url);
        webSettings = webView.getSettings();
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setLoadsImagesAutomatically(true);
        webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
        webSettings.setBlockNetworkImage(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        webView.setWebViewClient(new GoodsDetailWebViewClient());
    }

    private class GoodsDetailWebViewClient extends WebViewClient {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            webSettings.setBlockNetworkImage(false);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return true;
        }
    }

}
